package com.chixing.controller;


import com.chixing.entity.Myorder;
import com.chixing.service.IMyorderService;
import com.chixing.service.MyOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2022-10-14
 */
@RestController
//@RequestMapping("/myorder")
public class MyorderController {
    @Autowired
    private IMyorderService myorderService;

    @Autowired
    private MyOrder myOrder;

    @Value("{server.port}")
    private String serverPort;

    @GetMapping(value = "/order/{orderId}")
    public Map<String,Object> getById(@PathVariable("orderId") Integer id) {
        System.out.println("用户正在端口访问订单："+id);
        Map<String,Object> myorder = myOrder.getMyOrder(id);
        return myorder;
    }

    @PostMapping("saveOrder")
    public boolean save(Myorder order){
        System.out.println("添加成功:"+order);
        return myorderService.save(order);
    }
}
